package o;

import android.text.TextUtils;
import com.huawei.appmarket.service.pinyin.TransliteratorFunction;
import java.util.ArrayList;

public final class ede {
    private static final ede ˏ = new ede();
    private TransliteratorFunction ˎ;
    private TransliteratorFunction ॱ;

    private ede() {
        try {
            this.ˎ = new TransliteratorFunction("Han-Latin/Names; Latin-Ascii; Any-Upper");
            this.ॱ = new TransliteratorFunction("Latin-Ascii");
        } catch (RuntimeException e) {
            Logger.ˋ("HanziToPinyin", "RuntimeException");
        } catch (UnsatisfiedLinkError e2) {
            Logger.ˋ("HanziToPinyin", "UnsatisfiedLinkError");
        }
    }

    public static ede ˋ() {
        return ˏ;
    }

    public boolean ˎ() {
        return this.ˎ != null;
    }

    private void ˎ(char c, edg o_edg) {
        o_edg.ˊ(Character.toString(c));
        if (c < '') {
            o_edg.ˎ(1);
            o_edg.ॱ(o_edg.ˊ());
        } else if (c < 'ɐ' || ('Ḁ' <= c && c < 'ỿ')) {
            String ˊ;
            o_edg.ˎ(1);
            if (this.ॱ == null) {
                ˊ = o_edg.ˊ();
            } else {
                ˊ = this.ॱ.ˏ(o_edg.ˊ());
            }
            o_edg.ॱ(ˊ);
        } else {
            o_edg.ˎ(2);
            o_edg.ॱ(this.ˎ.ˏ(o_edg.ˊ()));
            if (TextUtils.isEmpty(o_edg.ॱ()) || TextUtils.equals(o_edg.ˊ(), o_edg.ॱ())) {
                o_edg.ˎ(3);
                o_edg.ॱ(o_edg.ˊ());
            }
        }
    }

    private void ˎ(StringBuilder stringBuilder, ArrayList<edg> arrayList, int i) {
        String stringBuilder2 = stringBuilder.toString();
        arrayList.add(new edg(i, stringBuilder2, stringBuilder2));
        stringBuilder.setLength(0);
    }

    public ArrayList<edg> ˋ(String str) {
        ArrayList<edg> arrayList = new ArrayList();
        if (!ˎ() || TextUtils.isEmpty(str)) {
            return arrayList;
        }
        int length = str.length();
        StringBuilder stringBuilder = new StringBuilder();
        edg o_edg = new edg();
        int i = 1;
        for (int i2 = 0; i2 < length; i2++) {
            char charAt = str.charAt(i2);
            if (!Character.isSpaceChar(charAt)) {
                ˎ(charAt, o_edg);
                if (o_edg.ˋ() == 2) {
                    if (stringBuilder.length() > 0) {
                        ˎ(stringBuilder, arrayList, i);
                    }
                    arrayList.add(o_edg);
                    o_edg = new edg();
                } else {
                    if (i != o_edg.ˋ() && stringBuilder.length() > 0) {
                        ˎ(stringBuilder, arrayList, i);
                    }
                    stringBuilder.append(o_edg.ॱ());
                }
                i = o_edg.ˋ();
            } else if (stringBuilder.length() > 0) {
                ˎ(stringBuilder, arrayList, i);
            }
        }
        if (stringBuilder.length() > 0) {
            ˎ(stringBuilder, arrayList, i);
        }
        return arrayList;
    }
}
